package com.zyw.module.console.dict.controller;

import com.zyw.module.console.dict.po.Dict;
import com.zyw.module.console.dict.service.DictService;
import com.zyw.mvc.servlet.BaseController;
import com.zyw.mvc.support.WrappedResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("${path.console.prefix}/dict")
public class DictController extends BaseController {
    @Autowired
    private DictService dictService;

    @RequestMapping("get")
    @ResponseBody
    public WrappedResult get(Integer id) {
        return wrappedSuccessResult(dictService.get(id));
    }

    @RequestMapping("save")
    @ResponseBody
    public WrappedResult save(Dict dict) {
        int i = dictService.insert(dict);
        if (i > 0) {
             return wrappedSuccessResult(null);
        } else {
            return wrappedFaliedResult("保存失败");
        }
    }
}